#include "Bullet.h"

Bullet::Bullet()
{
    init();
    loadTexture("media/models/Chaingunner/chaingunner_mf1.png");
    hide();
}

void Bullet::init()
{
    sphere();
    changeBoundingVolume(Solid::SPHERE);
    scale(0.1);
    position(10,0,10);
    label(LABEL::PARTICLE);
    body().gravityScale(0.0);
    body().damping(0.0);

    emissor.generate(Particle::GLOW);
    emissor.color(130,70,20);
    emissor.scale(0.1);
}


void Bullet::act()
{
    emissor.position() = position();
    tempoEmissao--;

    if (tempoEmissao < 0)
    {
        hide();
        emissor.stop();
    }
}

int Bullet::collide(Object& other)
{
    switch(other.label())
    {
        case LABEL::ENEMY:
            hide();
            break;
    }
    return true;
}

void Bullet::hide()
{
    visible(false);
    inactiveBody();
    emissor.stop();
}

void Bullet::appear()
{
    tempoEmissao = 30;
    visible(true);
    activeBody();
    emissor.start();
}
